package org.wzys.Controller;


import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.wzys.Pojo.Order;
import org.wzys.Pojo.Result;
import org.wzys.Pojo.Review;
import org.wzys.Service.OrderService;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/orders")
public class OrderController {


    @Autowired
    private OrderService orderService;

    //修改订单状态，支付成功实现接口
    @PutMapping
    public Result updateOrderStatus(@RequestParam String orderId) {
        log.info("修改订单状态，支付成功");
        orderService.updateOrderStatus(orderId);
        return Result.success();
    }

    @DeleteMapping
    public Result deleteOrder(@RequestParam String orderId) {
        log.info("删除订单");
        orderService.deleteOrder(orderId);
        return Result.success();
    }

    @GetMapping
    public Result getOrder() {
        log.info("获取订单");
        List<Order> order=orderService.showOrder();
        return Result.success(order);
    }

    @PostMapping("/review/add")
    public Result addReview(@RequestBody Review review) {
        log.info("添加评论");
        orderService.addReview(review);
        return Result.success();
    }

    @GetMapping("/review/show")
    public Result showReview(@RequestParam String orderId) {
        log.info("获取评论");
        List<Review> review=orderService.showReview(orderId);
        return Result.success(review);
    }
}
